﻿using BJ.AuthDomain.IService;
using Microsoft.AspNetCore.Mvc;
using Syspetro.Core.AppDeal;
using Syspetro.Core.DynamicApi;
using Syspetro.Core.GoogleAuth;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BJ.AuthApp.Admin
{
    public class AdminGoogleAuthApp : BaseDynamicApi
    {
        readonly IAdminGoogleAuthService _googleAuth;
        public AdminGoogleAuthApp(IAdminGoogleAuthService googleAuth)
        {
            _googleAuth = googleAuth;
        }
        /// <summary>
        /// 创建并绑定Google验证(管理员专用)
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<SpActionResult<GoogleBindingModel>> GenerateBind(Guid uid)
        {
            return await _googleAuth.GenerateBind(uid);
        }
        /// <summary>
        /// Google验证
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public async Task<SpActionResult<bool>> Validate(string code)
        {
            return await _googleAuth.Validate(code);
        }
        /// <summary>
        /// 判断Google验证
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public async Task<SpActionResult<bool>> IsSetGoogle(Guid uid)
        {
            return new SpActionResult<bool>(await _googleAuth.IsSetGoogle(uid));
        }
    }
}
